package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Comment;
import com.briup.recognition.bean.CommentExample;
import com.briup.recognition.dao.CommentMapper;
import com.briup.recognition.service.ICommentService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class CommentServiceImpl implements ICommentService {
    @Resource
    private CommentMapper commentMapper;

    @Override
    public List<Comment> query() {
        CommentExample example=new CommentExample();

        return commentMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Comment comment) {
        if(comment.getId()!=null){
            commentMapper.updateByPrimaryKey(comment);
        }else {
            commentMapper.insert(comment);
        }

    }

    @Override
    public void deleteById(long id) { commentMapper.deleteByPrimaryKey(id);

    }
}
